from common.unit import AndroidUI
from appium.webdriver.common.touch_action import TouchAction

#入库操作
class StorageObject:

    def __init__(self):
        self.driver = AndroidUI.get_webdriver()

    #"请扫描暂存间二维码"/"展厅暂存间已登录"提示
    def lib_msg(self):
        element = self.driver.find_element_by_id("com.bluephone:id/lib_msg")
        return element

    #批量到库按钮
    def lib_enter_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/lib_enter")
        return element

    #装箱按钮按钮
    def lib_packing_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/lib_packing")
        return element

    #逐袋复核按钮
    def lib_check_bag_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/lib_check_bag")
        return element

    #逐箱复核按钮
    def lib_check_box_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/lib_check_box")
        return element

    #左上角返回按钮
    def back_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/iv_back")
        return element

    #"请扫描暂存间二维码"提示
    #NO.22，自定义垃圾20.15kg，时间：2020-10-10 08:27:41
    def item_text(self):
        element = self.driver.find_element_by_id("com.bluephone:id/item_text")
        return element

    #"已入库提示"提示
    def item_adapter_status(self):
        element = self.driver.find_element_by_id("com.bluephone:id/item_adapter_status")
        return element

    # 箱列表按钮
    def listbox_button(self):
        element = self.driver.find_element_by_id("com.bluephone:id/listbox")
        return element

    #滑动操作
    def swipe(self,x,y,x2,y2):
        TouchAction(self.driver).press(x=x, y=y).move_to(x=x2, y=y2).release().perform()
        # TouchAction(self.driver).press(x=348, y=659).move_to(x=370, y=131).release().perform()
        print(f'从（{x}，{y}）滑动到（{x2}，{y2}）')

if __name__ == '__main__':
    sto=StorageObject()
